﻿using CI.Mesopotamia.WebService;
using NUnit.Framework;

namespace MesopotamiaDCProxy.SystemTests
{
    [TestFixture]
    public class DiagTests
    {
        InboundClient _wsclient;
        const string Hostversion = "hostversion";
        const string Machinename = "machinename";
        int _userid;

        /// <summary>
        /// setup tests
        /// </summary>
        [SetUp]
        public void Setup()
        {
            _wsclient = new InboundClient();
        }

        /// <summary>
        /// teardown
        /// </summary>
        [TearDown]
        public void Teardown()
        {
            _wsclient.Close();
        }
#if DEBUG
        /// <summary>
        /// get the number of users through the webservice
        /// </summary>
        [Test]
        public void DiagGetUsersDbCount_CheckValue_Greater()
        {
            // get the user id
            _userid = _wsclient.GetNewUserId(Machinename, Hostversion);
            Assert.Greater(_wsclient.DiagGetUsersDbCount(_userid), 0, "should be more then 0 users in the db");
        }
#endif

        /// <summary>
        /// ask the web service for a user id
        /// </summary>
        [Test]
        public void GetNewUserId_NotNull_Greater()
        {
            // get the user id
            Assert.Greater(_wsclient.GetNewUserId(Machinename, Hostversion), 0, "user id is zero");
        }

        /// <summary>
        /// ask the web service for a user id, should be same if the machine name and host name are same
        /// </summary>
        [Test]
        public void GetNewUserId_Samewsequal()
        {
            // get the user id
            Assert.AreEqual(_wsclient.GetNewUserId(Machinename, Hostversion), _wsclient.GetNewUserId(Machinename, Hostversion), "user id is zero");
        }

    }
}
